/*
 ============================================================================
 Name		: DocDetailView.cpp
 Author	  : JohnLZeng
 Copyright   : Your copyright notice
 Description : CDocDetailView implementation
 ============================================================================
 */

// INCLUDE FILES
#include <aknviewappui.h>
#include <eikmenup.h> 
#include "SHPlatform.h"
#include "DocDetailView.h"

//copy from ListenVoaAppView.cpp
//#include "ListenVoa.hrh"
//#include <ListenVoa_UID3.rsg>

// ============================ MEMBER FUNCTIONS ===============================
CDocDetailView::CDocDetailView()
	{
	// No implementation required
	iContainer = NULL;
	}

CDocDetailView::~CDocDetailView()
	{
	DoDeactivate();

	//add your code here ...
	}

CDocDetailView* CDocDetailView::NewLC()
	{
	CDocDetailView* self = new (ELeave) CDocDetailView();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CDocDetailView* CDocDetailView::NewL()
	{
	CDocDetailView* self = CDocDetailView::NewLC();
	CleanupStack::Pop(); // self;
	return self;
	}

void CDocDetailView::ConstructL()
	{
	BaseConstructL(R_VIEW_DOC_DETAIL);

	//add your code here...
	}
/**
 * 
 * */
TUid CDocDetailView::Id() const
	{
	return TUid::Uid(EListenVoaDocDetailViewId);
	}
void CDocDetailView::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case ECommandPlay:
			iContainer->Mp3Play();
			break;
		case ECommandPause:
			iContainer->Mp3Pause();
			break;
		case ECommandIncreaseVolume:
			iContainer->IncreaseVolume();
			break;
		case ECommandDecreaseVolume:
			iContainer->DecreaseVolume();
			break;
		case ECommandIncreaseFont:
			iContainer->IncreaseFont();
			break;
		case ECommandDecreaseFont:
			iContainer->DecreaseFont();
			break;			
		case EAknSoftkeyBack:
			SHChangeView(EListenVoaRSSBriefViewId);
			break;
		default:
			AppUi()->HandleCommandL(aCommand);
		}
	}
void CDocDetailView::HandleStatusPaneSizeChange()
	{
	if (iContainer != NULL)
		iContainer->SetRect(ClientRect());
	}

/**
 * 
 * */
void CDocDetailView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
		TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
	{
	if (!iContainer)
		{
		iContainer = CDocDetailContainer::NewL(ClientRect());
		iContainer->SetMopParent(this);
		AppUi()->AddToStackL(*this, iContainer);

		//add your init code ...

		}
	}
void CDocDetailView::DoDeactivate()
	{
	if (iContainer != NULL)
		{
		AppUi()->RemoveFromViewStack(*this, iContainer);
		
		delete iContainer;
		iContainer = NULL;
		}
	}

void CDocDetailView::DynInitMenuPaneL( TInt aResourceId, 
                                               CEikMenuPane* aMenuPane )
	{
	if (aResourceId == R_MENU_DOC_DETAIL)
		{
		switch (iContainer->GetState())
			{
			case CDocDetailContainer::ENotReady:
				aMenuPane->SetItemDimmed(ECommandPlay,  ETrue);
				aMenuPane->SetItemDimmed(ECommandPause, ETrue);	
				aMenuPane->SetItemDimmed(ECommandIncreaseVolume,  ETrue);
				aMenuPane->SetItemDimmed(ECommandDecreaseVolume,  ETrue);
				break;
			case CDocDetailContainer::EPlaying:
				aMenuPane->SetItemDimmed(ECommandPlay,  ETrue);
				aMenuPane->SetItemDimmed(ECommandPause, EFalse);	
				aMenuPane->SetItemDimmed(ECommandIncreaseVolume,  EFalse);
				aMenuPane->SetItemDimmed(ECommandDecreaseVolume,  EFalse);
				break;
			case CDocDetailContainer::EPause:
				aMenuPane->SetItemDimmed(ECommandPlay,  EFalse);
				aMenuPane->SetItemDimmed(ECommandPause, ETrue);
				aMenuPane->SetItemDimmed(ECommandIncreaseVolume,  EFalse);
				aMenuPane->SetItemDimmed(ECommandDecreaseVolume,  EFalse);
				break;
			case CDocDetailContainer::EReady:
				aMenuPane->SetItemDimmed(ECommandPlay,  EFalse);
				aMenuPane->SetItemDimmed(ECommandPause, ETrue);
				aMenuPane->SetItemDimmed(ECommandIncreaseVolume,  ETrue);
				aMenuPane->SetItemDimmed(ECommandDecreaseVolume,  ETrue);
				break;
			default:
				break;
			}
		}
	}
// End of File
